%\documentclass[twoside,titlepage]{report}

%\usepackage{fullpage}
%\usepackage{graphicx}
%\usepackage{verbatim}
%\usepackage{wrapfig}
%\usepackage{amsmath}
%\usepackage{moreverb}
%\newcommand{\loadsrc}[1]{
%\subsection{#1}
%{\scriptsize{
%\verbatimtabinput[8]{#1}}}
%}

%\begin{document}

To test the performance of Matpix, a set of identical programs were written both in Matpix and python and computation speed was compared.  Each program consists of an initialization of two matrices, an assignment to all their elements, and a loop performing a binary operation where the result is assigned to one of the matrices. Both the size of the two matrices, and the number of iterations the operations were varied in the test suite. The tests were run on a dual core iMac with a ATI x800 graphics card. As is evident in the add, subtract, multiply and divide plots below, Matpix shows strong performance gains for atomic arithmetic operations. For these operations, computation speed decreases exponentially with greater number of iterations, and the performance of Matpix is more than a factor of two greater than python for sufficiently large matrices. 

Much optimization is still required before Matpix can utilize the full computational power of the GPU. As an example, consider the performance of an example single purpose GPGPU program the authors tested on their home machine \cite{GPU_MATH}. The program consisted of 100 iterations of an atomic MAD operation performed on two 1,000,000 element arrays, and was 50 times faster when run on the GPU than when using a standard C program. In contrast, a Matpix program performing 128 iterations of a multiply operation on two 1024x1024 matrices is only 2.5  faster than a python program. From this comparison it is evident that significant optimization is required before Matpix can achieve the performance of fixed function GPGPU programs written directly in C using OpenGL. 

Once atomic operations are optimized, load balancing data transferring between the CPU and GPU can also be introduced to further achieve optimal execution speeds. The authors considered several possible methods for achieving this that were not implemented. When data transfer to and from the GPU does not outweigh the increase in computational efficiency, data transfer should be omitted, and  computations should be performed on the CPU. In addition, asymmetry between GPU memory read and  write speeds dictates that as many computations as possible should be performed inside each fragment program to minimize the number of write operations. Currently Matpix only performs one operation per fragment program for all operations but the dot product. The authors expected that this operation in particular would demonstrate significant speed improvements since it specifically avoids extraneous write operations. The figures below show that despite this expectation the Matpix dot product operator still performs well below that of python. The authors speculate that a performance increase was not demonstrated because the GPU code that is currently used in the Matpix backend is does not use the optimal OpenGL feature set which allows the computation to be shared by all of the fragment processors on the GPU.    
 
\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=6in]{figures/add.png} 
   \caption{Performance of atomic add operation}
\end{figure}

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=6in]{figures/sub.png} 
   \caption{Performance of atomic subtract operation}
\end{figure}

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=6in]{figures/mul.png} 
   \caption{Performance of atomic multiply operation}
\end{figure}

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=6in]{figures/div.png} 
   \caption{Performance of atomic divide operation}
\end{figure}

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=6in]{figures/dot.png} 
   \caption{Performance of atomic dot product operation}
\end{figure}

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=6in]{figures/eq.png} 
   \caption{Performance of atomic "is equal" test}
\end{figure}

\begin{figure}[htbp] %  figure placement: here, top, bottom, or page
   \centering
   \includegraphics[width=6in]{figures/trans.png} 
   \caption{Performance of atomic transpose operation}
\end{figure}

%\end{document}